package sf.database.template.enjoy;

import com.jfinal.template.Engine;
import sf.database.template.enjoy.ext.SqlKit;
import sf.tools.StringUtils;

public class EnjoyHelp {
    private static SqlKit sqlKit;
    public static boolean devMode = false;

    public static SqlKit getEnjoySqlKit() {
        if (sqlKit == null) {
            sqlKit = new SqlKit("SQL", devMode);
        }
        return sqlKit;
    }

    public static Engine getEnjoyEngine() {
        return getEnjoySqlKit().getEngine();
    }

    /**
     * 去除多余的换行符
     * @param input
     * @return
     */
    public static String deleteCRLFOnce(String input) {
        if (StringUtils.isNotBlank(input)) {
            return input.replaceAll("((\r\n)|\n)[\\s\t ]*(\\1)+", "$1").replaceAll("^((\r\n)|\n)", "");
        } else {
            return null;
        }
    }
}
